package com.shsmi.dsn.common;

public class Result {
    private Boolean success;
    private Integer code;
    private Object data;

    public Result(Boolean _success, Integer _code, Object _data) {
        this.success = _success;
        this.code = _code;
        this.data = _data;
    }

    public Boolean getSuccess() {
        return success;
    }

    public void setSuccess(Boolean success) {
        this.success = success;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public Object getData() {
        return data;
    }

    public Result setData(Object data) {
        this.data = data;
        return this;
    }

    public static Result genSuccessResult() {

        return new Result(true, Constants.DEFAULT_CODE_SUCCESS, null);
    }

    public static Result genSuccessResult(Object data) {
        return new Result(true, Constants.DEFAULT_CODE_SUCCESS, data);
    }

    public static Result genFailResult() {
        return new Result(false, Constants.DEFAULT_CODE_FAIL, null);
    }

    public static Result genFailResult(Integer code) {
        return new Result(false, code, null);
    }

    public static Result genFailResult(Integer code, Object data) {
        return new Result(false, code, data);
    }
}
